#!/usr/bin/env node

const http = require('http'),
      log = console.log,
      //url = require('url'),//对url进行解析
      addr = process.argv[2];

http.get(addr, (res)=>{//addr:请求的url地址,res流：响应体数据
  //print reaponse start line
  //HTTP/1.1  200 OK
  log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);

  //print reponse headers
  //Content-Length:22
  log(res.headers);
  
  //print response body
  res.pipe(process.stdout);



  //let data = '';
  //res.on('data',(chunck)=>{
  //data +=chunck;
  //});
  //res.on('end',()=>{
  //log(data);
  //});
});

